JavaScript Programming by Raasch Jon

JavaScript Programming by Raasch Jon
Author: Raasch, Jon [Raasch, Jon]
Language: eng
Format: epub
Publisher: Wiley
Published: 0101-01-01

If you want to manage multiple Node versions on the same system, install NVM: https://github.com/creationix/nvm.

Getting Started with Node

Although Node might seem intimidating at first, getting started is actually pretty easy. No intro to Node would be complete without the ubiquitous “Hello World” example, and I'm just as excited as you are.

Creating the Server

The first step is to open up a text editor and include the http module, which you use to create the HTTP server:

// load http module

var http = require('http');

Here you use the require() method to include the module. The http module is one of the core Node modules. (Later this chapter you learn more about modules and how to include external modules in your app.) Next, use the http module to create the server:

// load http module

var http = require('http');